<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增申请类型')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">申请类型名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="typeName" id="typeName" required>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "per/app/type";
	    
		$("#form-post-add").validate({
			onkeyup: false,
			rules:{
				typeName:{
					remote: {
		                url: prefix + "/checkTypeNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"typeName" : function() {
		                        return $.common.trim($("#typeName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				typeSort:{
					digits:true
				},
			},
			messages: {
		        "typeName": {
		            remote: "申请类型名称已经存在"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-post-add').serialize());
	        }
	    }
	</script>
</body>
</html>
